@include('Home.head')
<style>
	.choose {
	    position: relative;
	}
	
	.choose .radio {
	    position: relative;
	    display: inline-block;
	    font-weight: 400;
	    color: #0c4757;
	    padding-left: 25px;
	    cursor: pointer;
	}
	
	.choose .radio input {
	    position: absolute;
	    left: -9999px;
	}
	
	.choose .radio i {
	    display: block;
	    position: absolute;
	    top: 6px;
	    left: 0;
	    width: 15px;
	    height: 15px;
	    outline: 0;
	    border: 1px solid #e4e4e4;
	    background: #ffffff;
	    border-radius: 50%;
	    transition: border-color .3s;
	    -webkit-transition: border-color .3s;
	}
	
	.choose .radio input + i:after {
	    position: absolute;
	    content: '';
	    top: 2px;
	    left: 2px;
	    width: 9px;
	    height: 9px;
	    border-radius: 50%;
	    background-color: #ff5d5b;
	    opacity: 0;
	    transition: opacity .1s;
	    -webkit-transition: opacity .1s;
	}
	
	.choose .radio input:checked + i:after {
	    opacity: 1;
	}
</style>
<body>
<div class="container" id="app">
    <header data-am-widget="header" class="am-header am-header-default my-header" style="background-color: #FF9100;">
        
        <h1 class="am-header-title">
            <a href="#title-link" class="" style="color: #FFFFFFFF;font-size: 20px;">现场活动</a>
        </h1>
        
    </header>
    <div class="gray-panel">
        <div class="paoduct-title-panel" style="padding: 24px 10px;">
            
            <form class="am-form am-form-inline">
				<div class="am-form-group am-form-icon">
				    <i class="am-icon-user"></i>
				    <input type="text" v-model="name" class="am-form-field am-radius"  style="border: none;border-bottom: 1px solid #999999FF;" placeholder="姓名">
				</div>
				<div class="am-form-group am-form-icon">
				    <i class="am-icon-phone"></i>
				    <input type="number" v-model="phone" class="am-form-field am-radius" style="border: none;border-bottom: 1px solid #999999FF;" placeholder="手机号">
				</div>
				<div class="am-form-group am-form-icon">
				    <i class="am-icon-user"></i>
				    <input type="text" v-model="sharer_name" class="am-form-field am-radius" style="border: none;border-bottom: 1px solid #999999FF;" placeholder="推荐人姓名">
				</div>
				<div class="am-form-group am-form-icon">
				    <i class="am-icon-phone"></i>
				    <input type="number" v-model="sharer_phone" class="am-form-field am-radius" style="border: none;border-bottom: 1px solid #999999FF;" placeholder="推荐人电话(选填)">
				</div>
				<!-- <div class="am-form-group">
					<span>活动类型：</span>
				    <label class="am-radio-inline">
						 <input type="radio" v-model="activity_type" name="type" value="1"> vip(￥680)
				    </label>
					<label class="am-radio-inline">
						<input type="radio" v-model="activity_type" name="type" value="2"> 导师(￥2000)
					</label>
				</div> -->
				
				<div class="choose">
					<span>活动类型：</span>
				 <label class="radio" >699礼包<input type="radio" name="type" v-model="activity_type" value="1"><i></i></label>
{{--				 <label class="radio" style="margin-left: 20px;">区域合伙人<input type="radio" v-model="activity_type" value="2" name="type"><i></i></label>--}}
				</div>
				
				
                <p>
					<p><i class="am-icon-location-arrow"></i> 收货地址</p>
                <div id="address-form" data-toggle="distpicker">
                    <label class="sr-only" for="province1">省</label>
                    <select id="province1" v-model="province" required>
                    </select>
                    <div class="form-group">
                        <label for="city1">市</label>
                        <select class="form-control" id="city1" v-model="city" required>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="sr-only" for="district1" >区</label>
                        <select class="form-control" id="district1" v-model="district">
                        </select>
                    </div>
                </div>
                </p>
                <div class="am-form-group">
                    <input type="text" v-model="consignee_adr" class="am-form-field am-radius" placeholder="街道小区">
                </div>
                
                <input type="hidden" value="1" name="paytype" id="paytype">
                <p class="am-text-center"><button type="button" id="btn1" class="am-btn am-btn-danger am-radius am-btn-block" v-on:click="add()" style="background-color: #FF9100;border: none;border-radius: 26px;color: white;width: 150px;display:block;margin:0 auto;">完成</button></p>
            </form>
        </div>
    </div>

</div>
</body>
<script src="{{ URL::asset('js/address/distpicker.data.js') }}"></script>
<script src="{{ URL::asset('js/address/distpicker.js') }}"></script>
<script src="{{ URL::asset('js/address/main.js') }}"></script>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            address: {
                'phone':'' ,
                'name':'',
                'sharer_phone':'',
                'sharer_name':'',
                'province':'',
                'city':'',
                'district':'',
                'consignee_adr':'',
                'activity_type':1,
            },
			phone:'' ,
			name:'',
			sharer_phone:'',
			sharer_name:'',
			province:'',
			city:'',
			district:'',
			consignee_adr:'',
			activity_type:1,
        },
        methods: {
            //初始化 系统管理员列表
            initialize:function () {
                //编辑
                var id = this.obtain('id');
                if(id > 0){
                    $.post("/home/member/addaddress",{'_token':'{{csrf_token()}}',id:id,class:'find'},function (res) {
                        if(res.code){
                            app.address = res.data
                            $('#address-form').distpicker('destroy');
                            $("#address-form").distpicker({
                                province: app.address.province,
                                city: app.address.city,
                                district: app.address.district
                            });
                        } else {
                            layer.msg(res.data);
                        }
                    });
                }

            },
            //获取url id
            obtain:function (val) {
                var query = window.location.search.substring(1);
                var vars = query.split("&");
                for (var i=0;i<vars.length;i++) {
                    var pair = vars[i].split("=");
                    if(pair[0] == val){
                        return pair[1];
                    }
                }
            },
            isEmpty:function(obj) {
                if (obj === null) return true;
                if (typeof obj === 'undefined') {
                    return true;
                }
                if (typeof obj === 'string') {
                    if (obj === "") {
                        return true;
                    }
                    var reg = new RegExp("^([ ]+)|([　]+)$");
                    return reg.test(obj);
                }
                return false;
            },
            add:function () {
                app.address.province = $("#province1").val();
                app.address.city = $("#city1").val();
                app.address.district = $("#district1").val();

                // if (app.address.default) {
                //     app.address.default = 1
                // }else {
                //     app.address.default = 0
                // }

                // if( app.isEmpty(app.address.province) ){
                //     layer.msg('请选择所在省份!');
                //     return false;
                // }
                // if( app.isEmpty(app.address.city) ){
                //     layer.msg('请选择所在市!');
                //     return false;
                // }
                // if( app.isEmpty(app.address.district) ){
                //     layer.msg('请选择所在区!');
                //     return false;
                // }
                // if( app.isEmpty(app.address.address) ){
                //     layer.msg('请输入详细地址!');
                //     return false;
                // }
                // if(!(/^[1][3,4,5,7,8,9][0-9]{9}$/.test(app.address.phone))){
                //     layer.msg('请输入正确的电话号码');
                //     return false;
                // }
                $.post("/home/login/InformationEntry",{'_token':'{{csrf_token()}}',class:'add',phone:app.phone,name:app.name,sharer_phone:app.sharer_phone,sharer_name:app.sharer_name,province:app.province,city:app.city,district:app.district,consignee_adr:app.consignee_adr,activity_type:app.activity_type},function (res) {
                    if(res.code){
                         // layer.msg(res.data,{time:2000},function () {
                            window.location.href="http://zhuoma.baoliy168.com/home/login/success";
                        // });
                    } else {
                        layer.msg(res.data);
                    }
                });
            }
        },
        //自动执行
        mounted: function () {
            this.initialize();//分公司
        },
    });
</script>
</html>
